<%@codepage="65001"%>
<%session.codepage="65001"%>
<!-- #include virtual=/inc/dbConn.asp -->
<!-- #include virtual=/inc/function.asp -->
<%
	fullEstCd = Request("fullEstCd")
	divEstCd = split(fullEstCd, "-")
	if fullEstCd <> "" then 
		if divEstCd(1) <> "" then
			issueDt =  divEstCd(1)
			estCd= divEstCd(0)
			isPerms = aFieldValue("SELECT ISNULL(count(*),0) FROM tblEstimate WHERE convert(varchar(8),addDt,112)='" & issueDt & "' AND estCd='" & estCd & "'")
			if isPerms = 0 then
				Response.write "	<META http-equiv=""Content-Type"" content=""text/html; charset=utf-8"">"				
				Response.write "이 문서는 비정상적으로 접속 하였습니다.<br> This URL is incorrect." 
				Response.end
			end if 
		else
			estCd = Request("estCd")
		end if 
	else
			estCd = Request("estCd")
	end if 

	'## 공급자(노아텍) 정보
	Set compRs=Server.CreateObject("ADODB.RecordSet")
	SQL = "SELECT company, owner, compNo, phone, addr, compPart, compType FROM tblCompany WHERE compCd=1"	
	compRs.open SQL, dbCon
	
	If compRs.eof Or compRs.bof Then 
	Else 
		Do Until compRs.eof Or compRs.bof
			company 		= compRs("company")
			owner 			= compRs("owner")
			compNo 		= compRs("compNo")
			compPart 	= compRs("compPart")
			compType 	= compRs("compType")
			phone 			= compRs("phone")
			addr 			= compRs("addr")
		compRs.movenext
		Loop 
	End If
	
	
	'## 견적서 정보
	Set estRs=Server.CreateObject("ADODB.RecordSet")
	SQL = "SELECT company, major, projectNm, totalPrice, totalTax, totalAmount, remark, convert(varchar(10),addDt,121) issueDt, flag FROM tblEstimate WHERE estCd='" & estCd & "'"	
	estRs.open SQL, dbCon
	
	If estRs.eof Or estRs.bof Then 
	Else 
		Do Until estRs.eof Or estRs.bof
			estCompany 		= estRs("company")
			estMajor 				= estRs("major")
			estProjectNm 		= estRs("projectNm")
			estTotalPrice 		= estRs("totalPrice")
			estTotalAmount 	= estRs("totalAmount")
			estTotalTax 			= estRs("totalTax")
			estRemark 			= estRs("remark")
			estIssueDt 			= estRs("issueDt")
			flag 			= estRs("flag")
			If trim(estMajor) = "" Then estMajor = "담당자" End If 
		estRs.movenext
		Loop 
	End If
		
	printTime = date() & " " & time()
%>
<!-- #include virtual=/inc/header.inc.asp -->  
<script language = "JavaScript" src="/inc/js/ScriptX_TAG_SCM.js"></script>
<script>initScriptX("contexts", "100%", "100%"); </script>

<script for=window event=onload>
	printWindow(document.contexts, "<%=printTime%>");
	//self.close();
</script>


<script language="JavaScript">	 
	function printWindow(objName, DAY2) {
		var footer = "출력일시 : " + DAY2;
		objName.printing.header = "";
		objName.printing.footer = ""; //footer;
		objName.printing.portrait = true; // false 는 가로인쇄
		objName.printing.leftMargin = 15.0;
		objName.printing.topMargin = 15.0;
		objName.printing.rightMargin = 15.0;
		objName.printing.bottomMargin = 1.0;
		objName.printing.Print(false);
	}
</script>
<style>
.table_com {
	background-color: #FFFFFF;
	clear: both;
	border: 1px solid #333333; 
	font-size: 10px;
	line-height: 18px;
	padding: 3px 1px 3px 1px;
}
.table_com_orange {
	background-color: #FFFFFF;
	clear: both;
	border: 1px solid #ff6633; 
	border-bottom: 5px solid #ff6633; 
	font-size: 10px;
	line-height: 18px;
	padding: 3px 1px 3px 1px;
}
.table_com_cell td {
	background-color: #FFFFFF;
	clear: both;
	border-right: 1px solid #333333; 
	border-bottom: 1px solid #333333; 
	border-top: 1px solid #333333; 
	font-size: 11px;
	line-height: 18px;
	padding: 3px 1px 3px 1px;
}
.P_0rb0 {
	background-color: #FFFFFF;
	clear: both;
	border-right: 1px solid #333333; 
	border-bottom: 1px solid #333333; 
	font-size: 11px;
	line-height: 15px;
	padding: 3px 1px 3px 1px;
}
.P_0rbl {
	background-color: #FFFFFF;
	clear: both;
	border-right: 1px solid #333333; 
	border-bottom: 1px solid #333333; 
	border-left: 1px solid #333333; 
	font-size: 11px;
	line-height: 15px;
	padding: 3px 1px 3px 1px;
}
.P_trb0 {
	background-color: #FFFFFF;
	clear: both;
	border-right: 1px solid #333333; 
	border-bottom: 1px solid #333333; 
	border-top: 1px solid #333333; 
	font-size: 11px;
	line-height: 15px;
	padding: 3px 1px 3px 1px;
}
.P_trbl {
	background-color: #FFFFFF;
	clear: both;
	border-right: 1px solid #333333; 
	border-bottom: 1px solid #333333; 
	border-top: 1px solid #333333; 
	border-left: 1px solid #333333; 
	font-size: 11px;
	line-height: 15px;
	padding: 3px 1px 3px 1px;
}
.P_t0bl {
	background-color: #FFFFFF;
	clear: both;
	border-left: 1px solid #333333; 
	border-bottom: 1px solid #333333; 
	border-top: 1px solid #333333; 
	font-size: 11px;
	line-height: 15px;
	padding: 3px 1px 3px 1px;
}

hr {   
	border-width:20px 0px 0px 0px;
 	border-style:dotted;
 	border-color:#333333; 
 	height:1px;
 	}
</style>
 
<BODY topmargin="0" leftmargin="0">
	<table width="99.5%" cellpadding="0" cellspacing="0">
		<tr>
			<td>
				<table width="100%" cellpadding="0" cellspacing="0" border="0">
					<tr>
						<td width="25%" style="height:35px;text-align:left" valign="bottom">
							<!-- <table width="70%" cellpadding="0" cellspacing="0">
								<tr>
									<td width="30%" style="font-size:12px; text-align:Center;padding-left:10px;">일자 </td>
									<td width="70%" style="font-size:14px; font-weight:bold;padding-left:10px;">: &nbsp; <%=estIssueDt%></td>
								</tr>
							</table> -->
							&nbsp;
						</td>
						<td width="50%"  style="text-align:center;font-size:17pt;font-weight:bold;height:50px;color:#333333; border:2px solid #333333;">견 &nbsp; 적 &nbsp; 서</td>
						<td width="25%" style="height:35px;text-align:right" valign="bottom">		
							<!-- <table width="70%" cellpadding="0" cellspacing="0">
								<tr>
									<td width="100%" style="font-size:11pt; text-align:right;padding-right:10px;font-weight:bold;">NO. <%=estCd%> </td>
								</tr>
							</table> -->
							&nbsp;
						</td>
					</tr>
					<tr>
						<td colspan="3" width="100%" style="height:20px;font-size:11pt; text-align:right;padding-right:10px;font-weight:bold;">&nbsp;</td>
					</tr>
					<tr>
						<td colspan="3" width="100%" style="font-size:11pt; text-align:right;padding-right:10px;font-weight:bold;">NO. <%=estCd%> </td>
					</tr>
				</table>
			</td>
		</tr>
	</table>
	<table width="99.5%" cellpadding="0" cellspacing="0">
		<tr>
			<td style="height:10px"></td>
		</tr>
	</table>
	<table width="99.5%" cellpadding="0" cellspacing="0">
		<tr>
			<td width="40%">
				<table  width="99%" cellpadding="0" cellspacing="0">
					<tr>
						<td width="100%" style="text-align:center;height:38px;font-size:12pt;font-weight:bold;"><%=estCompany%></td>
					</tr>
					<tr>
						<td width="100%" style="text-align:center;height:25px;font-size:12px;"><%=estMajor%>님 귀하</td>
					</tr>
					<tr>
						<td width="100%" style="text-align:center;height:20px;font-size:12px;">&nbsp; </td>
					</tr>
					<tr>
						<td width="100%" style="text-align:center;height:30px;font-size:12px;"><%=estIssueDt%> </td>
					</tr>
					<tr>
						<td width="100%" style="text-align:center;height:25px;font-size:12px;">아래와 같이 견적합니다.</td>
					</tr>
				</table>
			</td>
			<td width="60%" valign="top" align="right">
				<table  width="99%" cellpadding="0" cellspacing="0">
					<tr>
						<td colspan="4" width="100%" class="P_trbl" style="text-align:center;height:28px;font-size:12px;"> 공급자</td>
					</tr>
					<tr>
						<td width="18%" class="P_0rbl" style="height:26px;font-size:10px;text-align:center">등록번호</td>
						<td width="82%" colspan="3" class="P_0rb0" style="height:26px;font-size:10px;text-align:center"><%=compNo%>&nbsp;</td>
					</tr>
					<tr>
						<td width="18%" class="P_0rbl" style="height:28px;font-size:10px;text-align:center">상호</td>
						<td width="32%" class="P_0rb0" style="height:28px;font-size:10px;text-align:center"><%=company%></td>
						<td width="18%" class="P_0rb0" style="height:26px;font-size:10px;text-align:center">성명</td>
						<td width="32%" class="P_0rb0" style="height:26px;font-size:10px;padding-left:7px;"><%=owner%></td>
					</tr>
					<tr>
						<td width="18%" class="P_0rbl" style="height:28px;font-size:10px;text-align:center">업태</td>
						<td width="32%" class="P_0rb0" style="height:28px;font-size:10px;text-align:center">&nbsp;<%=compType%></td>
						<td width="18%" class="P_0rb0" style="height:26px;font-size:10px;text-align:center">종목</td>
						<td width="32%" class="P_0rb0" style="height:26px;font-size:10px;text-align:center">&nbsp;<%=compPart%></td>
					</tr>
					<tr>
						<td width="18%" class="P_0rbl" style="height:26px;font-size:10px;text-align:center">주소</td>
						<td width="82%" colspan="3" class="P_0rb0" style="height:40px;font-size:10px;text-align:center">&nbsp;<%=addr%></td>
					</tr>
					<tr>
						<td width="18%" class="P_0rbl" style="height:28px;font-size:10px;text-align:center">담당자</td>
						<td width="32%" class="P_0rb0" style="height:28px;font-size:10px;text-align:center">&nbsp;</td>
						<td width="18%" class="P_0rb0" style="height:26px;font-size:10px;text-align:center">전화번호</td>
						<td width="32%" class="P_0rb0" style="height:26px;font-size:10px;text-align:center">&nbsp;<%=phone%></td>
					</tr>
				</table>
			</td>
		</tr>
	</table>	
	<table width="99.5%" cellpadding="0" cellspacing="0" style="margin-top:10px;">
		<tr>
			<td width="30%" class="P_trbl" style="height:30px;font-size:12pt;text-align:center;font-weight:bold;">PROJECT NAME</td>
			<td width="35%" class="P_trb0" style="height:30px;font-size:12pt;text-align:center;"><%=estProjectNm%></td>
		</tr>
		<tr>
			<td width="30%" class="P_0rbl" style="height:30px;font-size:12pt;text-align:center;font-weight:bold;">합계 금액(공급가액+세액)</td>
			<td width="35%" class="P_0rb0" style="height:30px;font-size:12pt;text-align:right;padding-right:5px;"><%=formatnumber(estTotalPrice,0)%> 원</td>
		</tr>
	</table>
	<table width="99.5%" cellpadding="0" cellspacing="0" style="margin-top:10px;">
		<tr>
			<td width="32%" class="P_trbl" style="height:28px;font-size:11px;text-align:center;">품 명</td>
			<td width="10%" class="P_trb0" style="height:28px;font-size:11px;text-align:center;">단 위</td>
			<td width="10%" class="P_trb0" style="height:28px;font-size:11px;text-align:center;">수 량</td>
			<td width="8%" class="P_trb0" style="height:28px;font-size:11px;text-align:center;">단 가</td>
			<td width="16%" class="P_trb0" style="height:28px;font-size:11px;text-align:center;">공급가액</td>
			<td width="14%" class="P_trb0" style="height:28px;font-size:11px;text-align:center;">세 액</td>
		</tr>
<%

	'## 거래명세서 세부항목
	Set estArticleRs=Server.CreateObject("ADODB.RecordSet")
	SQL = "SELECT prdNm, unit, unitPrice, amount, articlePrice, articleTax FROM tblEstimateArticle A INNER JOIN tblEstimate B ON A.estCd=B.estCd " & _
		  "WHERE A.flag='Y' AND B.estCd='" & estCd & "'"
	estArticleRs.open SQL, dbCon
	C = 1
	If estArticleRs.eof Or estArticleRs.bof Then 
	Else 
		Do Until estArticleRs.eof Or estArticleRs.bof
			prdNm = estArticleRs("prdNm")
			unit= estArticleRs("unit")	
			unitPrice = FormatNumber(estArticleRs("unitPrice"),0)
			amount = FormatNumber(estArticleRs("amount"),0)
			articlePrice = FormatNumber(estArticleRs("articlePrice"),0)
			articleTax = FormatNumber(estArticleRs("articleTax"),0)
%>
		<tr>
			<td width="32%" class="P_0rbl" style="height:28px;font-size:11px;text-align:center;"><%=prdNm%></td>
			<td width="10%" class="P_0rb0" style="height:28px;font-size:11px;text-align:center;"><%=unit%></td>
			<td width="10%" class="P_0rb0" style="height:28px;font-size:11px;text-align:right;padding-right:5px;"><%=amount%></td>
			<td width="8%" class="P_0rb0" style="height:28px;font-size:11px;text-align:right;padding-right:5px;"><%=unitPrice%></td>
			<td width="16%" class="P_0rb0" style="height:28px;font-size:11px;text-align:right;padding-right:5px;"><%=articlePrice%></td>
			<td width="14%" class="P_0rb0" style="height:28px;font-size:11px;text-align:right;padding-right:5px;"><%=articleTax%></td>
		</tr>

<%
		C = C+1
		estArticleRs.movenext
		Loop 
	End If
%>		
		<tr>
			<td width="100%" class="P_0rbl" colspan="6" style="height:28px;font-size:11px;text-align:center;">- 이 상 -</td>
		</tr>
<%		
	for K = C to 10 
%>		
		<tr>
			<td width="32%" class="P_0rbl" style="height:28px;font-size:11px;text-align:center;">&nbsp;</td>
			<td width="10%" class="P_0rb0" style="height:28px;font-size:11px;text-align:center;">&nbsp;</td>
			<td width="10%" class="P_0rb0" style="height:28px;font-size:11px;text-align:right;padding-right:5px;">&nbsp;</td>
			<td width="8%" class="P_0rb0" style="height:28px;font-size:11px;text-align:right;padding-right:5px;">&nbsp;</td>
			<td width="16%" class="P_0rb0" style="height:28px;font-size:11px;text-align:right;padding-right:5px;">&nbsp;</td>
			<td width="14%" class="P_0rb0" style="height:28px;font-size:11px;text-align:right;padding-right:5px;">&nbsp;</td>
		</tr>
<%
	next
%>		
		<tr>
			<td width="72%" colspan="4" class="P_0rbl" style="height:30px;font-size:12pt;text-align:center;">합 계</td>
			<td width="16%" class="P_0rb0" style="height:30px;font-size:12pt;text-align:right;padding-right:5px;"><%=formatnumber(estTotalAmount,0)%></td>
			<td width="14%" class="P_0rb0" style="height:30px;font-size:12pt;text-align:right;padding-right:5px;"><%=formatnumber(estTotalTax,0)%></td>
		</tr>
<% if estRemark <> "" then %>		
		<tr>
			<td width="100%" colspan="6" class="P_0rbl" style="padding-left:10px;font-size:12px;height:27px;">※ <%=estRemark%></td>
		</tr>
<%	end if %>		
	</table>
	<table border="0" width="99.5%" cellpadding="0" cellspacing="0">
		<tr>
			<td valign="top" width="40%">
				<table width="99.5%" cellpadding="0" cellspacing="0">
					<tr>
						<td style="height:23px;font-size:10px">출력일시 : <%=printTime%></td>
					</tr>
				</table>
			</td>
			<td align="right" width="60%"><img src="/img/logo.jpg" width="150"></td>
		</tr>
	</table>
<div style="position:absolute;top:126px;left:593px;width:56px;height:50px;background-color:#fff;z-index:3;border:0;padding:0;">
	<img src="/img/sign.jpg">
</div>
<!--
<div style="position:absolute;top:345px;left:273px;width:56px;height:50px;background-color:#fff;z-index:3;border:0px solid #000;padding:0;">
	<img src="/img/sign.jpg">
</div>
-->
<% if flag = "N" then %>
<div style="position:absolute;top:100px;left:190px;width:56px;height:50px;z-index:4;border:0;padding:0;">
	<span style="text-align:center;color:#ff0000;font-weight:bold;font-size:20pt;border:#FF0000 5px solid;width:300px;height:100px;padding-top:40px;margin-bottom:<%=imgPosit%>px;">----------- 폐  기 -----------</span>
	<span style="text-align:center;color:#ff0000;font-weight:bold;font-size:20pt;border:#FF0000 5px solid;width:300px;height:100px;padding-top:40px;">----------- 폐  기 -----------</span>
</div>
<% end if %>
</BODY>
</HTML>
<%session.codepage="949"%>